package top.zhdev.community.entity;

import java.util.HashMap;
import java.util.Map;

/**
 * 事件模型，用户消息队列
 */
public class Event {
    private String topic;
    private int userId;
    private int entityType;
    private int entityId;
    // 实体作者id
    private int entityUserId;

    /*
    把其他额外的数据，存入map中，用于后期扩展
     */
    private Map<String,Object> data = new HashMap<>();

    public String getTopic() {
        return topic;
    }

    /*
    此处这样设计，是为了更灵活的设置属性，避免使用多个构造函数。
    这样设计很灵活和方便,可以连续的使用 . 方法，因为每次set后，都会返回Event实体，例如
    Event event = new Event()
                .setTopic(TOPIC_COMMENT)
                .setUserId(hostHolder.getUser().getId())
                .setEntityType(comment.getEntityType())
                .setEntityUserId(comment.getEntityId())
                .setData("postId", discussPostId);
     */
    public Event setTopic(String topic) {
        this.topic = topic;
        return this;
    }

    public int getUserId() {
        return userId;
    }

    public Event setUserId(int userId) {
        this.userId = userId;
        return this;
    }

    public int getEntityType() {
        return entityType;
    }

    public Event setEntityType(int entityType) {
        this.entityType = entityType;
        return this;
    }

    public int getEntityId() {
        return entityId;
    }

    public Event setEntityId(int entityId) {
        this.entityId = entityId;
        return this;
    }

    public int getEntityUserId() {
        return entityUserId;
    }

    public Event setEntityUserId(int entityUserId) {
        this.entityUserId = entityUserId;
        return this;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public Event setData(String key,Object value) {
        this.data.put(key,value);
        return this;
    }
}
